<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>种子管理·思通投研·让数据驱动投资价值!</title>
	<link href="${pageContext.request.contextPath }/img/webLogoIcon.png" rel="shortcut icon">
    <link href="${pageContext.request.contextPath }/css/bootstrap.min.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath }/css/font-awesome.css" rel="stylesheet">

    <link href="${pageContext.request.contextPath }/css/animate.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath }/css/style.css" rel="stylesheet">
    

	<link href="${pageContext.request.contextPath }/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">

    <!-- FooTable -->
    <link href="${pageContext.request.contextPath }/css/footable.core.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath }/css/datepicker3.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/css/mypage.css" rel="stylesheet">
    <style>
		.select2_demo_1{
			float: left;
			width: 120px;
			display: inline;
			margin-left: 10px;
		}
		.form-control{
			display: inline;
		}
		
		.col-sm-3{
			float:right;
			width: 560px;
		}
		.input-group{
			float:right;
			width: 240px;
			margin-left: 5px;
		}
	   td{
	        vertical-align:middle;
	    }
	</style>

</head>

<body>

    <div id="wrapper">

        <nav class="navbar-default navbar-static-side" role="navigation">
            <%request.setAttribute("LEFT", "smartseedlist");%>
			<%@include file="left.jsp"%>
        </nav>

        <div id="page-wrapper" class="gray-bg">
        <div class="row border-bottom">
         <jsp:include page="head.jsp" flush="true" /> 
        </div>
        <div class="row wrapper border-bottom white-bg page-heading">
            <div class="col-lg-9">
                <h2>种子管理</h2>
                <ol class="breadcrumb">
                	<li class="nav-main1">
                		<a href="${pageContext.request.contextPath}/admin/tosystem_overview">主页</a>
                	</li>
                	<li class="nav-main2" >
                			<a id="navigation1" href="#" >站点资源</a>
                	</li>
                	<li class="active">
                		<a >种子管理</a>
                	</li>
                </ol>
            </div>
        </div>

        <div class="wrapper wrapper-content animated fadeInRight">
            <div class="row">
                <div class="col-lg-12">
                    <div class="ibox float-e-margins">
                        <div class="ibox-content">
<!--                         	<div class="btn btn-primary pull-left">以下是昨日未采集到数据的种子信息</div> -->

                <div class="col-sm-3 search2">
					<div class="input-group serch1" style="display:none;">
                     	<input type="text" style="height: 34px;" placeholder="输入搜索内容" class="input-sm form-control"> <span class="input-group-btn">
                        <button type="button" class="btn btn-sm btn-primary" style="height: 34px;"> 搜索</button> </span>
                    </div>
                </div>
                        	
                        	
                <br />
                
               
	            
	            <table class="footable table table-stripped toggle-arrow-tiny" data-page-size="25"><!-- data-page-size="25" -->
                                <thead>
                                <tr>
                                    <th style="width: 15%;">种子名称</th>
                                    <th style="width: 15%;">种子所在网站名称</th>
                                    <th style="width: 10%;">今日抓取量</th>
                                    <th style="width: 10%;">抓取总量</th>
                                    <th style="width: 10%;">种子状态</th>
                                    <th style="width: 10%;">状态修改</th>
                                    <th style="width: 15%;">查看详情</th>
                                    <th style="width: 15%;">编辑种子</th>
                                </tr>
                                </thead>
                                <tbody>
                                <c:forEach items="${list.list}" var="seed">
											<tr>
												<td>${seed.seed_name}</td>
													<td>${seed.website_name }</td>
<%-- 												<c:set var="seed_datestr" value="${seed.create_date}" /> --%>
<%-- 												<c:set var="seed_create_date" value="${fn:substring(seed_datestr, 0, 19)}" /> --%>
												<td>${seed.todaynum}</td>
												<td>${seed.totalnum}</td>
												<c:if test="${seed.seed_status==1}">
													<td><span id="typetitle${seed.id}" style="line-height: 2;" class="label label-primary">运行中</span></td>
													<td><button id="typebutton${seed.id}" type="button"
															onclick="updateSeedflag(${seed.id},1)"
															class="btn-white btn btn-xs">关闭</button></td>
												</c:if>
												<c:if test="${seed.seed_status==0}">
													<td><span id="typetitle${seed.id}" style="line-height: 2;" class="label label-danger">已关闭</span></td>
													<td><button  id="typebutton${seed.id}"  type="button"
															onclick="updateSeedflag(${seed.id},0)"
															class="btn-white btn btn-xs">开启</button></td>
												</c:if>
												<td><button type="button"
														onclick="window.location.href = '${pageContext.request.contextPath}/getseeddetail?seedid=${seed.id}'"
														class="btn-white btn btn-xs">种子详情</button></td>
												<td><a style="color: inherit;" onclick="window.location.href = '${pageContext.request.contextPath}/getseedconfig?seedid=${seed.id }'"><i class="fa fa-edit"></i>&nbsp;编辑</a></td>
											</tr>
										</c:forEach>
                                </tbody>
                                <tfoot>
                                <tr>
                                    <td colspan="7">
                                        <c:if test="${list.pages>0}">
											<div class="box" id="box" style="float: right;"></div>
										</c:if>
                                    </td>
                                </tr>
                                </tfoot>
                            </table>

                        </div>
                    </div>
                </div>
        </div>
        </div>
<jsp:include page="footer.jsp" flush="true" />
        </div>
        </div>


    <!-- Mainly scripts -->
    <script src="${pageContext.request.contextPath }/js/jquery-2.1.1.js"></script>
    <script src="${pageContext.request.contextPath }/js/bootstrap.min.js"></script>
    <script src="${pageContext.request.contextPath }/js/jquery.metisMenu.js"></script>
    <script src="${pageContext.request.contextPath }/js/jquery.slimscroll.min.js"></script>

    <!-- Custom and plugin javascript -->
    <script src="${pageContext.request.contextPath }/js/inspinia.js"></script>
    <script src="${pageContext.request.contextPath }/js/pace.min.js"></script>
    


    <!-- FooTable -->
    <script src="${pageContext.request.contextPath }/js/footable.all.min.js"></script>
    <script src="${pageContext.request.contextPath}/js/mypage.js"></script>
    
    <script src="${pageContext.request.contextPath }/js/plugins/toastr/toastr.min.js"></script>
	<!-- Sweet alert -->
	<script src="${pageContext.request.contextPath }/js/plugins/sweetalert/sweetalert.min.js"></script>
	
    <!-- Page-Level Scripts -->
    <script>
        $(document).ready(function() {

            $('.footable').footable();

        });
        $(function(){
			paging(1,'${list.pages }','${list.pageNum }');
		});
		function paging(totalData,totalPage, pagenum) {
			$('#box').paging({
				initPageNo : pagenum, // 初始页码
				totalPages : totalPage, //总页数
				totalCount : '合计' + totalData + '条数据', // 条目总数
				slideSpeed : 600, // 缓动速度 单位毫秒
				jump : true, //是否支持跳转
				callback : function(page) {
					// 回调函数
				}
			});
		}

		function JumpToPage(pagenum) {
				window.location.href = "${pageContext.request.contextPath}/website/smartseedlist?pageNum=" +pagenum;
			
		}
		
		
function updateSeedflag(id,status) {
        	
        	swal({
                title: "确定修改?",
//              text: "Your will not be able to recover this imaginary file!",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                closeOnConfirm: false,     
                closeOnCancel: true },
            function (isConfirm) {
                if (isConfirm) {
                    
                    $.ajax({
                        url:"${pageContext.request.contextPath}/updateSeedflag?status="+status+"&id="+id,
                        type:"get",
                        success:function(res){
                            if (res.status == 200){
                                /* $("#seed").empty();
                                $("#seed").load(location.href + " #seed"); */
                                if(status == 1){
                                $("#typetitle"+id).attr("class","label label-danger");
                                $("#typetitle"+id).html("已关闭");
                                $("#typebutton"+id).attr("onclick","updateSeedflag("+id+",0)");
                                $("#typebutton"+id).html("开启");
                                }
                                if(status == 0){
                                    $("#typetitle"+id).attr("class","label label-primary");
                                    $("#typetitle"+id).html("运行中");
                                    $("#typebutton"+id).attr("onclick","updateSeedflag("+id+",1)");
                                    $("#typebutton"+id).html("关闭");
                                    }
                                swal("修改成功", "状态已改变", "success");
                                
                            }
                        },
                        error:function(e){
                        	swal("修改失败", "状态未改变", "error");
                        }
                    })
                } 
            });
        	
        	
		}
		
		//跑马灯方法 
// 		 function init(){
// 			    //获取标题
// 			    var title=document.title;
// 			    //分割字符串--->字符数组
// 			    var arr=title.split("");
// 			    //删除第一个元素并返回该元素
// 			    var e=arr.shift();
// 			    //把一个对象添加到数组末尾
// 			    arr.push(e);
// 			    //把数组转换成字符串
// 			    var marquee=arr.join("");
// 			    //返回给浏览器
// 			    document.title=marquee;
// 			    //定时一直执行
// 			    window.setTimeout("init()",1000);
// 			}
// 			window.onload=init;
		 
		
    </script>

    <!-- FooTable -->


</body>

</html>
